package com.xm.web.service.impl;

import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xm.web.consts.MagicNumEnum;
import com.xm.web.entity.po.TbPermission;
import com.xm.web.mapper.TbPermissionMapper;
import com.xm.web.service.ITbPermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xm.web.utils.PermissionTreeUtil;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 权限表 服务实现类
 * </p>
 *
 * @author yousj
 * @since 2021-08-18
 */
@Service
public class TbPermissionServiceImpl extends ServiceImpl<TbPermissionMapper, TbPermission> implements ITbPermissionService {

    @Override
    public List<Tree<Integer>> all() {
        return PermissionTreeUtil.permissions2tree(baseMapper.selectList(Wrappers.<TbPermission>lambdaQuery()
                .eq(TbPermission::getStatus, MagicNumEnum.ON.getCode())));
    }
}
